{include file="public/header" /}
<blockquote class="layui-elem-quote">
    附件管理
</blockquote>
<table class="layui-hide" id="table"></table>
{include file="public/footer" /}
<script>
    layui.use(["table", "tableBar", "popup", "util", "flow"], function () {
        var table = layui.table;
        var tableBar = layui.tableBar;
        var popup = layui.popup;
        var util = layui.util;
        var flow = layui.flow;

        // 表单
        table.render({
            elem: "#table",
            url: "{:url('admin.attachment.query')}",
            toolbar: `<div><button type="button" class="layui-btn layui-btn-normal layui-btn-xs" kllxs-on="add">添加</button></div>`,
            cols: [[
                { fixed: 'left', title: '主键', field: "id", align: 'center', width: 80 },
                { title: '类别', field: 'category', align: 'center' },
                { title: '名称', field: 'name', align: 'center' },
                { title: '文件', field: 'url', align: 'center', templet: tableBar.file("url") },
                { title: '类型', field: 'type', align: 'center' },
                { title: '大小(MB)', field: 'size', align: 'center' },
                { title: '格式', field: 'spec', align: 'center' },
                { title: '存储', field: 'storage', align: 'center', hide: true },
                { title: '创建时间', field: 'create_time', align: 'center', hide: true },
                { title: '更新时间', field: 'update_time', align: 'center', hide: true },
                { title: "操作", minWidth: 100, fixed: 'right', align: 'center', templet: tableBar.more() }
            ]],
            method: "post",
            limits: [10, 25, 50, 100],
            page: true,
            done: function (res, curr, count, origin) {
                // 配合图片懒加载
                flow.lazyimg({
                    elem: '.lazyimg img'
                });
            }
        })

        tableBar.util({
            edit: '{:url("admin.attachment.edit")}',
            del: '{:url("admin.attachment.del")}'
        });

        util.on("kllxs-on", {
            add: function () {
                popup.iframe('{:url("admin.attachment.add")}')
            }
        })
    })
</script>